package com.zeny.coding.dto;


import com.zeny.coding.enmus.ResponseStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <h2>统一响应类型</h2>
 *
 * @Author Zeny
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> {
    private Boolean success;
    private String code;
    private String message;
    private T data;

    public Response<T> success() {
        this.success = ResponseStatusEnum.SUCCESS.getSuccess();
        this.code = ResponseStatusEnum.SUCCESS.getCode();
        this.message = ResponseStatusEnum.SUCCESS.getMessage();
        return this;
    }
    public Response<T> fail() {
        this.success = ResponseStatusEnum.FAIL.getSuccess();
        this.code = ResponseStatusEnum.FAIL.getCode();
        this.message = ResponseStatusEnum.FAIL.getMessage();
        return this;
    }
    public Response<T> exception() {
        this.success = ResponseStatusEnum.EXECPTION.getSuccess();
        this.code = ResponseStatusEnum.EXECPTION.getCode();
        this.message = ResponseStatusEnum.EXECPTION.getMessage();
        return this;
    }

    public Response<T> data(T data) {
        this.data = data;
        return this;
    }
    public Response<T> code(String code) {
        this.code = code;
        return this;
    }
    public Response<T> message(String message) {
        this.message = message;
        return this;
    }
}
